home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Games / NeXTmille / Source / types.c < prev   
Text File  |  1994-04-30  |  5KB  |  247 lines

  1. /*
  2.  * Copyright (c) 1982 Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms are permitted
  6.  * provided that the above copyright notice and this paragraph are
  7.  * duplicated in all such forms and that any documentation,
  8.  * advertising materials, and other materials related to such
  9.  * distribution and use acknowledge that the software was developed
  10.  * by the University of California, Berkeley.  The name of the
  11.  * University may not be used to endorse or promote products derived
  12.  * from this software without specific prior written permission.
  13.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  14.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  15.  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  16.  */
  17.  
  18. #ifndef lint
  19. static char sccsid[] = "@(#)types.c    5.3 (Berkeley) 6/18/88";
  20. #endif /* not lint */
  21.  
  22. #import    "CardView.h"
  23. #import    "mille.h"
  24. #import    "prototypes.h"
  25. #import    <assert.h>
  26.  
  27.  
  28. /*
  29.  * @(#)types.c    1.1 (Berkeley) 4/1/82
  30.  */
  31.  
  32. BOOL    isDistance( CardView *aCard )
  33. {
  34.  
  35.     BOOL    retVal = NO;
  36.     
  37.     
  38.     switch([ aCard tag ]) {
  39.         case C_200:
  40.         case C_100:
  41.         case C_75:
  42.         case C_50:
  43.         case C_25:
  44.             retVal = YES;
  45.     }
  46.     
  47.     return retVal;
  48. }
  49.  
  50.  
  51. BOOL    isSafety( CardView *aCard )
  52. {
  53.  
  54.     BOOL    retVal = NO;
  55.     
  56.     
  57.     switch([ aCard tag ]) {
  58.         case C_EXTRA_TANK_SAFETY:
  59.         case C_PUNCTURE_PROOF_SAFETY:
  60.         case C_DRIVING_ACE_SAFETY:
  61.         case C_RIGHT_OF_WAY_SAFETY:
  62.             retVal = YES;
  63.     }
  64.     
  65.     return retVal;
  66. }
  67.  
  68.  
  69. BOOL    isRemedy( CardView *aCard )
  70. {
  71.  
  72.     BOOL    retVal = NO;
  73.  
  74.  
  75.     switch([ aCard tag ]) {
  76.         case C_GASOLINE_REMEDY:    
  77.         case C_SPARE_TIRE_REMEDY:        
  78.         case C_REPAIRS_REMEDY:        
  79.         case C_ROLL_REMEDY:        
  80.         case C_END_OF_LIMIT_REMEDY:
  81.             retVal = YES;
  82.     }
  83.     
  84.     return retVal;
  85. }
  86.  
  87.  
  88. BOOL    isHazard( CardView *aCard )
  89. {
  90.  
  91.     BOOL    retVal = NO;
  92.     
  93.     
  94.     switch([ aCard tag ]) {
  95.         case C_OUT_OF_GAS_HAZARD:        
  96.         case C_FLAT_TIRE_HAZARD:            
  97.         case C_ACCIDENT_HAZARD:        
  98.         case C_STOP_HAZARD:        
  99.         case C_SPEED_LIMIT_HAZARD:
  100.             retVal = YES;
  101.     }
  102.     
  103.     return retVal;
  104. }
  105.  
  106.  
  107. BOOL    isRemedyForHazard( CardView *hazard, CardView *remedy ) 
  108. {
  109.  
  110.     
  111.     if(([ hazard tag ] == C_OUT_OF_GAS_HAZARD ) && (([ remedy tag ] == C_GASOLINE_REMEDY ) || ([ remedy tag ] == C_EXTRA_TANK_SAFETY )))
  112.         return YES;
  113.     
  114.     if(([ hazard tag ] == C_FLAT_TIRE_HAZARD ) && (([ remedy tag ] == C_SPARE_TIRE_REMEDY ) || ([ remedy tag ] == C_PUNCTURE_PROOF_SAFETY )))
  115.         return YES;
  116.     
  117.     if(([ hazard tag ] == C_ACCIDENT_HAZARD ) && (([ remedy tag ] == C_REPAIRS_REMEDY ) || ([ remedy tag ] == C_DRIVING_ACE_SAFETY )))
  118.         return YES;
  119.     
  120.     if(([ hazard tag ] == C_STOP_HAZARD ) && (([ remedy tag ] == C_ROLL_REMEDY ) || ([ remedy tag ] == C_RIGHT_OF_WAY_SAFETY )))
  121.         return YES;
  122.     
  123.     if(([ hazard tag ] == C_SPEED_LIMIT_HAZARD ) && (([ remedy tag ] == C_END_OF_LIMIT_REMEDY ) || ([ remedy tag ] == C_RIGHT_OF_WAY_SAFETY )))
  124.         return YES;
  125.     
  126.     return NO;
  127. }
  128.  
  129.  
  130. int    distanceCardValue( CardView *aCard )
  131. {
  132.  
  133.     int    value = 0;
  134.     
  135.     
  136.     switch([ aCard tag ]) {
  137.         case C_200:
  138.             value = 200;
  139.             break;
  140.         case C_100:
  141.             value = 100;
  142.             break;
  143.         case C_75:
  144.             value = 75;
  145.             break;
  146.         case C_50:
  147.             value = 50;
  148.             break;
  149.         case C_25:
  150.             value = 25;
  151.             break;
  152.         default:
  153.             perror( "unknown card value" );
  154.     }
  155.     
  156.     return value;
  157. }
  158.  
  159.  
  160. int    safetyForHazard( int aCardTag )
  161. {
  162.  
  163.  
  164.     switch( aCardTag ) {
  165.         case C_STOP_HAZARD:
  166.         case C_SPEED_LIMIT_HAZARD:
  167.             return C_RIGHT_OF_WAY_SAFETY;
  168.         case C_ACCIDENT_HAZARD:
  169.             return C_DRIVING_ACE_SAFETY;
  170.         case C_FLAT_TIRE_HAZARD:
  171.             return C_PUNCTURE_PROOF_SAFETY;
  172.         case C_OUT_OF_GAS_HAZARD:
  173.             return C_EXTRA_TANK_SAFETY;
  174.         default:
  175.             assert( 0 /* unknown hazard card passed */ );
  176.     }
  177.     
  178. }
  179.  
  180.  
  181. int    hazardForRemedy( int aCardTag )
  182. {
  183.  
  184.     
  185.     switch( aCardTag ) {
  186.         case C_GASOLINE_REMEDY:        
  187.             return    C_OUT_OF_GAS_HAZARD;
  188.         case C_SPARE_TIRE_REMEDY:        
  189.             return C_FLAT_TIRE_HAZARD;
  190.         case C_REPAIRS_REMEDY:        
  191.             return C_ACCIDENT_HAZARD;
  192.         case C_ROLL_REMEDY:        
  193.             return C_STOP_HAZARD;    
  194.         case C_END_OF_LIMIT_REMEDY:    
  195.             return C_SPEED_LIMIT_HAZARD;
  196.         default:
  197.             assert( 0 /* bad remedy card */ );
  198.     }
  199.     
  200. }
  201.  
  202.  
  203. int    remedyForHazard( int aCardTag )
  204. {
  205.  
  206.  
  207.     switch( aCardTag ) {
  208.         case C_OUT_OF_GAS_HAZARD:
  209.             return C_GASOLINE_REMEDY;    
  210.         case C_FLAT_TIRE_HAZARD:
  211.             return C_SPARE_TIRE_REMEDY;            
  212.         case C_ACCIDENT_HAZARD:
  213.             return C_REPAIRS_REMEDY;        
  214.         case C_STOP_HAZARD:
  215.             return C_ROLL_REMEDY;            
  216.         case C_SPEED_LIMIT_HAZARD:
  217.             return C_END_OF_LIMIT_REMEDY;    
  218.         default:
  219.             assert( 0 /* bad hazard card */ );
  220.     }
  221.  
  222. }
  223.  
  224.  
  225. int    safetyForRemedy( int aCardTag )
  226. {
  227.  
  228.  
  229.     switch( aCardTag ) {
  230.         case C_GASOLINE_REMEDY:        
  231.             return    C_EXTRA_TANK_SAFETY;
  232.         case C_SPARE_TIRE_REMEDY:        
  233.             return C_PUNCTURE_PROOF_SAFETY;
  234.         case C_REPAIRS_REMEDY:        
  235.             return C_DRIVING_ACE_SAFETY;
  236.         case C_ROLL_REMEDY:        
  237.         case C_END_OF_LIMIT_REMEDY:    
  238.             return C_RIGHT_OF_WAY_SAFETY;    
  239.         default:
  240.             assert( 0 /* bad remedy card */ );
  241.     }
  242.     
  243. }
  244.  
  245.  
  246.  
  247.